<template>
  <div>
  <h1>排房</h1>
   <table>
    <tbody>
      <tr>
        <td>房型</td>
        <td>
          <select v-model="info.fx">
            <option :value="0">请选择房型</option>
            <option :value="1">大床房</option>
            <option :value="2">普通</option>
          </select>
        </td>
      </tr>

      <tr>
        <td>房号</td>
        <td>
          <select >
            <option :value="0">请选择房号</option>
            <option :value="item.id" v-for="item in infor1">{{item.fhcnam}}</option>
          </select>          
        </td>
      </tr>
      <tr>
        <td>
        未排
        </td>
        <td>
          <input type="text">
        </td>
      </tr>
     

      <tr>
        <td></td>
        <td>
          <input type="button" value="增加" @click="Adr" class="btn btn-success">
        </td>
      </tr>
    </tbody>
   </table>
  </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue';
import axios from 'axios'
import { useRoute,useRouter } from 'vue-router';
let route=useRoute();
let router=useRouter()

onMounted(()=>{
  Xlk();
  Fhao();
})
const infor = ref([{
  "id": 0,
  "fjcname": "",
}])
const Xlk=()=>{
  axios.get("https://localhost:7177/api/Fx/Shwo").then(res=>{
    infor.value=res.data
  })
}

const infor1 = ref([{
  "id": 0,
  "fhcnam": "",
}])

const Fhao=()=>{
  axios.get("https://localhost:7177/api/Fhao/Shoxlk").then(res=>{
    infor1.value=res.data
  })
}


const info =reactive({
 "id": 0,
  "fx": 0,
  "hhao": 0,
  "xxHZ": 0
})

const Adr=()=>{
  axios.post("https://localhost:7177/api/Pf/Addtj",info).then(res=>{
  if(res.data>0)
  {
      alert('添加成功');
      router.push('/PaiShow')
  }
 else{
    alert('添加失败');
    return;
  }
  })
 
}
</script>

<style scoped>

</style>